package com.zhao.data.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * 对象关系映射配置，包括JPA ，Mybatis，Hibernate
 * 
 * @author zhaoyongfei
 *
 */
@Configuration
@EnableTransactionManagement(proxyTargetClass = true)
@EnableJpaRepositories(basePackages = "com.zhao.data.repository")
@PropertySource("classpath:config/application-data.properties")
public class DataConfig {

	/**
	 * 屏蔽mybatis 警告
	 * 
	 * @param sqlSessionFactory
	 * @return
	 */

	//	@Bean
	//	public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
	//		SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
	//		sqlSessionFactoryBean.setDataSource(dataSource);
	//		return sqlSessionFactoryBean.getObject();
	//	}
	//
	//	@Bean
	//	public MapperScannerConfigurer mapperScannerConfigurer() {
	//		MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
	//		mapperScannerConfigurer.setBasePackage("com.zhao.data.mapper");
	//		return mapperScannerConfigurer;
	//	}
	//
	//	@Bean
	//	@Scope("prototype")
	//	public SqlSessionTemplate sqlSession(SqlSessionFactory sqlSessionFactory) {
	//		SqlSessionTemplate sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactory);
	//		return sqlSessionTemplate;
	//	}
}
